//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet
{
    public class WorkbookProperties : IOfficeXmlSerializable
    {

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
{
 	   using (ReadContext c = context.Read("workbookPr"))
    {
        bool b = c.GetOptionalBoolean("date1904", false);
           DateTimeOrigin = b ? DateTimeOrigin.Origin1904 : DateTimeOrigin.Origin1900;
        //DateTimeOrigin = c.GetOptionalBoolean("date1904", false);
        ShowObjects = c.GetOptionalEnum("showObjects", ObjectDisplayType.All);
        ShowBorderUnselectedTable = c.GetOptionalBoolean("showBorderUnselectedTable", true);
        FilterPrivacy = c.GetOptionalBoolean("filterPrivacy", false);
        PromptedSolutions = c.GetOptionalBoolean("promptedSolutions", false);
        showInkAnnotation = c.GetOptionalBoolean("showInkAnnotation", false);
        backupFile = c.GetOptionalBoolean("backupFile", false);
        saveExternalLinkValues = c.GetOptionalBoolean("saveExternalLinkValues", true);
        updateLinks = c.GetOptionalEnum("updateLinks", UpdateLinks.UserSet);
        codeName = c.GetOptionalString("codeName");
        hidePivotFieldList = c.GetOptionalBoolean("hidePivotFieldList", false);
        showPivotChartFilter = c.GetOptionalBoolean("showPivotChartFilter", false);
        allowRefreshQuery = c.GetOptionalBoolean("allowRefreshQuery", false);
        publishItems = c.GetOptionalBoolean("publishItems", false);
        checkCompatibility = c.GetOptionalBoolean("checkCompatibility", false);
        autoCompressPictures = c.GetOptionalBoolean("autoCompressPictures", true);
        defaultThemeVersion = c.GetOptionalInteger("defaultThemeVersion");
    }
}

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("workbookPr"))
            {
                c.SetOptionalBoolean("date1904", DateTimeOrigin == DateTimeOrigin.Origin1904, false);
                c.SetOptionalEnum("showObjects", ShowObjects, ObjectDisplayType.All);
                c.SetOptionalBoolean("showBorderUnselectedTable", ShowBorderUnselectedTable, true);
                c.SetOptionalBoolean("filterPrivacy", FilterPrivacy, false);
                c.SetOptionalBoolean("promptedSolutions", PromptedSolutions, false);
                c.SetOptionalBoolean("showInkAnnotation", showInkAnnotation ,false);
                c.SetOptionalBoolean("backupFile", backupFile , false);
                c.SetOptionalBoolean("saveExternalLinkValues", saveExternalLinkValues , true);
                c.SetOptionalEnum("updateLinks", updateLinks , UpdateLinks.UserSet);
                c.SetOptionalString("codeName", codeName);
                c.SetOptionalBoolean("hidePivotFieldList", hidePivotFieldList , false);
                c.SetOptionalBoolean("showPivotChartFilter", showPivotChartFilter , false);
                c.SetOptionalBoolean("allowRefreshQuery", allowRefreshQuery , false);
                c.SetOptionalBoolean("publishItems", publishItems , false);
                c.SetOptionalBoolean("checkCompatibility", checkCompatibility , false);
                c.SetOptionalBoolean("autoCompressPictures", autoCompressPictures , true);
                c.SetOptionalInteger("defaultThemeVersion", defaultThemeVersion);
            }
        }

        #endregion

        private bool allowRefreshQuery;

        public bool AllowRefreshQuery
        {
            get { return allowRefreshQuery; }
            set { allowRefreshQuery = value; }
        }
	

        private int? defaultThemeVersion;

        public int? DefaultThemeVersion
        {
            get { return defaultThemeVersion; }
            set { defaultThemeVersion = value; }
        }
	

        private bool checkCompatibility;

        public bool CheckCompatibility
        {
            get { return checkCompatibility; }
            set { checkCompatibility = value; }
        }
	

        private bool publishItems;

        public bool PublishItems
        {
            get { return publishItems; }
            set { publishItems = value; }
        }
	

        private bool showPivotChartFilter;

        public bool ShowPivotChartFilter
        {
            get { return showPivotChartFilter; }
            set { showPivotChartFilter = value; }
        }
	

        private bool hidePivotFieldList;

        public bool HidePivotFieldList
        {
            get { return hidePivotFieldList; }
            set { hidePivotFieldList = value; }
        }
	

        private bool autoCompressPictures = true;

        public bool AutoCompressPictures
        {
            get { return autoCompressPictures; }
            set { autoCompressPictures = value; }
        }
	
        private string codeName;

        public string CodeName
        {
            get { return codeName; }
            set { codeName = value; }
        }
	

        private UpdateLinks updateLinks;

        public UpdateLinks UpdateLinks
        {
            get { return updateLinks; }
            set { updateLinks = value; }
        }

        private DateTimeOrigin _date1904 = DateTimeOrigin.Origin1900;

        public DateTimeOrigin DateTimeOrigin
        {
            get { return _date1904; }
            set { _date1904 = value; }
        }
        private ObjectDisplayType _showObjects;

        public ObjectDisplayType ShowObjects
        {
            get { return _showObjects; }
            set { _showObjects = value; }
        }
        private bool showBorderUnselectedTables = true;

        public bool ShowBorderUnselectedTable
        {
            get { return showBorderUnselectedTables; }
            set { showBorderUnselectedTables = value; }
        }
        private bool filterPrivacy;

        public bool FilterPrivacy
        {
            get { return filterPrivacy; }
            set { filterPrivacy = value; }
        }
        private bool promptedSolutions;

        public bool PromptedSolutions
        {
            get { return promptedSolutions; }
            set { promptedSolutions = value; }
        }
        private bool showInkAnnotation;

        public bool ShowInkAnnotation
        {
            get { return showInkAnnotation; }
            set { showInkAnnotation = value; }
        }
        private bool backupFile;

        public bool BackupFile
        {
            get { return backupFile; }
            set { backupFile = value; }
        }

        private bool saveExternalLinkValues = true;

        public bool SaveExternalLinkValue
        {
            get { return saveExternalLinkValues; }
            set { saveExternalLinkValues = value; }
        }
	
	
	
	
	
	
	
    }
}
